<template>
	<view class="categoryContainer">
		<view class="header">
			<view class="headerLeft">
				<view class="headerLeftText">分类</view>
			</view>
			<view class="headerRight">
				<view class="headerRightText">品牌</view>
			</view>
				<image class="headerImg" src="../../static/images/ss.png"></image>
		</view>
		<view class="categoryMain">
			<view class="BoxLeft">
				<view class="Left" v-for="(category,index) in cateList" :key="categoryList.cateid"  @click="isChange(index)">
					<view class="leftBox" :class="currentIndex===index && 'active'">{{category.name}}</view>
				</view>
				<!-- <view class="Left" v-for="(category,index) in cateList" :key="categoryList.cateid"  @click="currentIndex=index" :class="{active:currentIndex===index}">{{category.name}}
				</view> -->
			</view>
			<scroll-view class="RightscrollView" scroll-y="true" >
					<view class="RightTop">
						<view class="header">
							<view class="headerText">{{Title[0].title}}</view>
							<view class="headerText2">全部></view>
						</view>
						<view class="headerMain">
							<view class="MainBox" v-for="topThing in topCateList" :key="topThing.id_param">
								<image class="MainImg" :src="topThing.photo" @click="toshopList"></image>
								<text class="MainName">{{topThing.name}}</text>
							</view>
						</view>
					</view>
					<view class="Rightbottom">
						<view class="bottomheader">{{Title[1].title}}</view>
						<view class="bottomMain">
							<view class="bottomBox" v-for="bottomThing in bottomCateList" :key="bottomThing.target.param">
								<image class="bottomImg" :src="bottomThing.logo"></image>
								<text class="bottomName">{{bottomThing.name}}</text>
							</view>
						</view>
					</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {mapGetters} from 'vuex'
	export default {
		data() {
			return {
				currentIndex:0
			}
		},
		mounted(){
			this.getCateList()
		},
		methods:{
			getCateList(){
				this.$store.dispatch('getCateList')
			},
			//点击切换狗狗商品分类
			isChange(index){
				this.currentIndex=index
			},
			//点击去到商品列表页
			toshopList(){
				wx.navigateTo({
					url:"/pages/shopList/shopList"
				})
			}
		},
		computed:{
			...mapGetters(['cateList']),
			Title(){
				return (this.cateList[this.currentIndex] || {}).cate_list || []
			},
			topCateList(){
				return (((this.cateList[this.currentIndex] || {}).cate_list || [])[0] || {}).list || []
			},
			bottomCateList(){
				return (((this.cateList[this.currentIndex] || {}).cate_list || [])[1] || {}).list || []
			}
		}
	}
</script>

<style lang="stylus">
	.categoryContainer
		.header
			width 100%
			height 80rpx
			font-size 40rpx
			display flex
			justify-content space-around
			.headerLeft
				width 345rpx
				height 80rpx
				.headerLeftText
					width 80rpx
					height 80rpx
					color #00a200
					text-align center
					line-height 80rpx
					margin-left 220rpx
					border-bottom 5rpx solid #00bf00
			.headerRight
				width 345rpx
				height 80rpx
				.headerRightText
					width 80rpx
					line-height 80rpx
					margin-right 100rpx
			.headerImg
				width 35rpx
				height 35rpx
				margin-top 25rpx
				margin-right 50rpx
		.categoryMain
			display flex
			border-top 2rpx solid #cfcfcf
			.BoxLeft
				display flex
				flex-direction column
				.Left
					width 140rpx
					height 10%
					border-right 5rpx solid #3F536E
					.leftBox
						width 140rpx
						height 100rpx
						text-align center
						line-height 100rpx
						&.active
							color #00A200
							border-bottom 2rpx solid #c3c3c3
				// .Left
				// 	width 140rpx
				// 	height 10%
				// 	border-right 5rpx solid #3F536E
				// 	height 100rpx
				// 	text-align center
				// 	line-height 100rpx
				// 	&.active
				// 		color #00A200
				// 		border-bottom 2rpx solid #c3c3c3
			.RightscrollView
				width 600rpx
				height calc(100vh - 80rpx)
				display flex
				flex-direction column
				.RightTop
					width 600rpx
					height 364rpx
					border-bottom 2rpx solid #cbcbcb
					display flex
					flex-direction column
					.header
						width 580rpx
						height 80rpx
						line-height 80rpx
						.headerText
							font-size 35rpx
							margin-top 10rpx
						.headerText2
							font-size 30rpx
							margin-top 15rpx
							margin-left 200rpx
					.headerMain
						width 580rpx
						height 254rpx
						display flex
						.MainBox
							width 194rpx
							height 234rpx
							display flex
							flex-direction column
							align-items center
							margin-left 20rpx 
							margin-top 20rpx
							margin-bottom 10rpx
							.MainImg
								width 174rpx
								height 174rpx
							.MainName
								font-size 30rpx
								margin-top 20rpx
				.Rightbottom
					width 600rpx
					height 830rpx
					.bottomheader
						width 580rpx
						height 80rpx
						line-height 80rpx
						font-size 35rpx
						margin-top 10rpx
						margin-left 20rpx
					.bottomMain
						width 100%
						padding 10rpx
						// background-color #007AFF
						display flex
						flex-wrap wrap
						.bottomBox
							width 50%
							height 180rpx
							// background-color #00A200
							text-align center
							.bottomImg
								width 270rpx
								height 110rpx
								margin 10rpx
							.bottomName
								font-size 30rpx
								display: -webkit-box;
								-webkit-box-orient: vertical;
								-webkit-line-clamp: 1;
								overflow: hidden;
</style>
